<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>基于GIS的公路网规划综合评价系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=GBK" />
    <style>
        .bg {
            background-color: #3299ff ;/*此处更换为所需的颜色代码*/
            background-image:url("image/login.jpg");
            height:600px;

        }
        .bt{
            position:absolute;
            top:345px;
            margin:0 950px;
        }
        .bb{

        }
        button{
            margin-top: 15px;
            margin-right: 48px;
        }
        span{
            color: cornsilk;
        }
        a{
            color:black;
            text-decoration:none;
        }

    </style><!DOCTYPE html>
</head>

<body onkeydown="sub();">
<h1 style="text-align:center">基于GIS的公路网规划综合评价系统</h1>

<div  class="bg">
    <div class="bb">
    <div class="bt">
    <form >
        <span >用户名：</span><input type="text" id="username" name="username" value="" style="display: inline-block;width:200px;">
        <span>密码：</span><input type="text" id="password" name="password" value="" style="display: inline-block;width:200px;">
        <button type="button" onclick="check()">登录</button> <button  ><a  th:action="@{/register}">注册</a></button>
    </form>
    </div>
    </div>
</div>

</body>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script th:inline="javascript">
    function check() {
        var adminName = $("#username").val();
        var adminPassword = $("#password").val();
        if (adminName=="" || adminPassword==""){
            alert("用户名密码不能为空");
            return false;
        }
        else {
            var htmlobj =   $.ajax({
                url:"http://localhost:8080/user/login",
                type:'POST',
                data:{username:adminName,password:adminPassword},
                success:function (message) {
                    if (message.status==0){

                        window.location.href='http://localhost:8080/index ';
                    }
                    else {
                        alert(message.msg);
                    }
                },
                //async:false
            });
            // alert("11");
            /*var res = eval("("+htmlobj.responseText+")");
            var status = res.status;
            alert(status);
            if (status==0)*/
        }
    }
</script>
</html>

